package com.zbf.service;

import com.zbf.dao.TestMapper;
import com.zbf.entity.TestUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/9/9  9:38
 * 描述:  事务的嵌套调用
 */
@Component
public class TestQianTaoShiWu {

    @Autowired
    private TestMapper testMapper;

    @Autowired
    private TestQianTao2 testQianTao2;

    @Transactional(timeout = 1,propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public void test1(){
        TestUser testUser=new TestUser();
        testUser.setId(5L);
        testUser.setUserName("55555555555555");
        testMapper.updateById(testUser);
        testQianTao2.test3();
    }


    @Transactional(timeout = 10,propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public void test2(){
        int i = testMapper.deleteById(6L);
    }



}
